home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / diskmags / amiga_9310b.lha / Tips & Tricks / Tastatur.c < prev   
Encoding:
C/C++ Source or Header  |  1993-08-24  |  1.5 KB  |  74 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <intuition/intuition.h>
  4. #include <libraries/dos.h>
  5. #include <clib/exec_protos.h>
  6.  
  7. struct ConsoleDevice *ConsoleDevice=NULL;
  8. struct IOStdReq ioreq;
  9.  
  10. long DeadKeyConvert(struct
  11.     IntuiMessage *msg,
  12.     UBYTE *buffer,long size,
  13.     struct KeyMap *map ) {
  14. static struct InputEvent
  15. ievent={NULL,IECLASS_RAWKEY,0,0,0};
  16.  
  17. if( msg->Class!=RAWKEY )
  18.   return( -2 );
  19. ievent.ie_Code=msg->Code;
  20. ievent.ie_Qualifier=msg->Qualifier;
  21. ievent.ie_position.ie_addr=
  22.           *((APTR *)msg->IAddress);
  23. return( (LONG)RawKeyConvert(
  24.  &ievent,(char *)buffer,size,map));
  25. }
  26.  
  27. int GetKey(struct IntuiMessage
  28.      *message, UBYTE *ibuf ) {
  29.   LONG  numchars;
  30.   UBYTE buffer[15];
  31.   strcpy( buffer,"           " );
  32.   if( message->Code>=0x00 &&
  33.           message->Code<=0x40 ) {
  34.     // ASCII-Code
  35.     numchars=DeadKeyConvert(
  36.          message, buffer,15,0L );
  37.     if( numchars>0 ) {
  38.       *ibuf=*buffer;
  39.       return ASCII;
  40.     }
  41.   }
  42.   /* hier steht der tastencode */
  43.   switch( message->Code ) {
  44.     case 0x41:
  45.          return BACKSPACE;
  46.     case 0x42:
  47.          return TAB;
  48.     case 0x43:
  49.     case 0x44:
  50.          return ENTER;
  51.     ...
  52.   }
  53. }
  54.  
  55. main() {
  56.   char buf;
  57.   struct IntuiMessage *imessage;
  58.   OpenDevice("console.device",-1L,
  59.     (struct IORequest *)&ioreq,0L);
  60.   ConsoleDevice=ioreq.io_Device;
  61.   /*
  62.    * Hier erfolgt eine Schleife
  63.    * und übergeben die Intuition-
  64.    * Message
  65.    */
  66.   GetKey( intuimessage,&ibuf );
  67.   /*
  68.    * In buf steht nun der ASCII-Code
  69.    */
  70.  
  71.   /* Und wieder schließen */
  72.   CloseDevice( ioreq );
  73. }
  74.